<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'user-form',
	'enableAjaxValidation'=>false,

    'htmlOptions' => array(
        'enctype' => 'multipart/form-data'
    )
));

    if(!isset($enabled)){
        $enabled = true;
    }
?>

    <p class="note">Обязательные поля <span class="required">*</span></p>

	<?php echo $form->errorSummary($model); ?>

    <?php if($model->path_to_avatar): ?>
    <div class="user_create_left_column">
        <div class="row">
            <?php echo $form->labelEx($model,'path_to_avatar'); ?>
            <?php echo CHtml::image($model->path_to_avatar, '', array('class'=>'avatar')); ?>
            <?php echo $form->error($model,'path_to_avatar'); ?>
        </div>
    </div>
    <?php endif; ?>
    <div class="user_create_right_column">
        <? if($enabled): ?>
        <div class="row">
            <?php echo $form->labelEx($model,'avatar'); ?>
            <?php echo CHtml::activeFileField($model, 'avatar'); ?>
            <?php echo $form->error($model,'avatar'); ?>
        </div>
        <? endif; ?>

        <div class="row">
            <?php echo $form->labelEx($model,'full_name'); ?>
            <? if($enabled): ?>
                <?php echo $form->textField($model,'full_name',array('size'=>50,'maxlength'=>120)); ?>
            <? else:echo $model->full_name;
             endif; ?>
            <?php echo $form->error($model,'full_name'); ?>
        </div>

        <div class="row">
            <?php echo $form->labelEx($model,'email'); ?>
            <? if($enabled): ?>
                <?php echo $form->textField($model,'email',array('size'=>50,'maxlength'=>50)); ?>
            <? else: echo $model->email;
             endif; ?>
            <?php echo $form->error($model,'email'); ?>
        </div>

        <div class="row">
            <?php echo $form->labelEx($model,'username'); ?>
            <? if($enabled): ?>
                <?php echo $form->textField($model,'username',array('size'=>50,'maxlength'=>50)); ?>
            <? else: echo $model->username; endif; ?>
            <?php echo $form->error($model,'username'); ?>
        </div>

        <? if($enabled): ?>
            <div class="row">
                <?php echo $form->labelEx($model,'password'); ?>
                <?php echo $form->passwordField($model,'password',array('size'=>50,'maxlength'=>256)); ?>
                <?php echo $form->error($model,'password'); ?>
            </div>

            <div class="row">
                <?php echo $form->labelEx($model,'password_repeat'); ?>
                <?php echo $form->passwordField($model,'password_repeat',array('size'=>50,'maxlength'=>256)); ?>
                <?php echo $form->error($model,'password_repeat'); ?>
            </div>
        <? endif; ?>

        <? if(isset($_SESSION['user']) and $_SESSION['user']->type != User::CLIENT): ?>
            <?php echo $form->labelEx($model,'type'); ?>
            <? if($enabled): ?>
                <? echo CHtml::activeDropDownList($model, 'type', CHtml::listData($model->getTypes(), 'id', 'name'));?>
            <? else: echo $model->getVerboseType(); endif; ?>
            <?php echo $form->error($model,'password'); ?>
        <? endif; ?>

        <? if($model->phone or $enabled): ?>
            <div class="row">
                <?php echo $form->labelEx($model,'phone'); ?>
                <? if($enabled): ?>
                    <?php echo $form->textField($model,'phone',array('size'=>50,'maxlength'=>20)); ?>
                <? else: echo $model->phone; endif; ?>
                <?php echo $form->error($model,'phone'); ?>
            </div>
        <? endif; ?>

        <?php if(Yii::app()->user->isGuest and $enabled): ?>
        <div class="row">
            <?php echo $form->labelEx($model,'verification_code'); ?>
            <div>
            <?php $this->widget('CCaptcha'); ?><br/>
            <?php echo $form->textField($model,'verification_code'); ?>
            </div>
            <div class="hint">Заполните поле символами, указанными на изображении.
            <br/>Символы не чувствительны к регистру.</div>
            <?php echo $form->error($model,'verification_code'); ?>
        </div>
        <?php endif; ?>

        <div class="row_buttons">
            <? if($enabled): ?>
                <?php echo CHtml::submitButton($model->isNewRecord ? 'Создать' : 'Сохранить'); ?>
            <? endif; ?>
        </div>
    </div>

<?php $this->endWidget(); ?>

</div><!-- form -->